package com.forum.module.system.dal.mysql.user_role;

import com.forum.framework.common.pojo.PageResult;
import com.forum.framework.mybatis.core.mapper.BaseMapperX;
import com.forum.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.forum.module.system.controller.admin.role.vo.RolePageReqVO;
import com.forum.module.system.dal.dataobject.user_role.UserRoleDO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
    default PageResult<UserRoleDO> selectPage(RolePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserRoleDO>()
                .eqIfPresent(UserRoleDO::getUserId, reqVO.getUserId()));
    }

    default UserRoleDO selectByUserId(Long userId){
        return selectOne(new LambdaQueryWrapperX<UserRoleDO>()
                .eqIfPresent(UserRoleDO::getUserId, userId));
    }
}
